//
//  FitnessVideoCollectionViewController.m
//  B
//
//  Created by lanou on 16/5/17.
//  Copyright © 2016年 裴启航. All rights reserved.
//

#import "FitnessVideoCollectionViewController.h"
#import "FitnessVideoCollectionViewCell.h"
#import "TrainingTableViewController.h"

@interface FitnessVideoCollectionViewController ()

@property (nonatomic, strong) NSArray *listArray;
@property (nonatomic, strong) NSArray *urlArrs;

@end

@implementation FitnessVideoCollectionViewController

static NSString * const reuseIdentifier = @"Cell";
//- (instancetype)init
//{
//    UICollectionViewFlowLayout *layout = [[UICollectionViewFlowLayout alloc]init];
////    layout.itemSize
////    layout.minimumInteritemSpacing
//    
//    return [super initWithCollectionViewLayout:layout];
//}
- (void)viewDidLoad {
    [super viewDidLoad];
    
    // Uncomment the following line to preserve selection between presentations
    // self.clearsSelectionOnViewWillAppear = NO;
    // Register cell classes
    // Do any additional setup after loading the view.
    self.navigationItem.title = @"健康视频";
    [self.collectionView registerNib:[UINib nibWithNibName:@"FitnessVideoCollectionViewCell" bundle:nil] forCellWithReuseIdentifier:reuseIdentifier];
    self.collectionView.backgroundColor = [UIColor whiteColor];
    self.listArray = @[@"胸部训练", @"肩部训练", @"背部训练", @"腿部训练", @"手臂训练", @"腰腹训练"];
    self.urlArrs = @[@"http://henan.sinaimg.cn/2012/0208/U5019P827DT20120208140319.jpg", @"http://img.weixinyidu.com/150526/2f00b6cf.jpg", @"http://s15.sinaimg.cn/mw690/a2aff8f2gcf625916e9be&6900", @"http://efit.cn/UserFiles/2014/6/17/3202420140617030432.jpg", @"http://p2.pstatp.com/large/3812/3126360048", @"http://photocdn.sohu.com/20150923/mp33071432_1443006605875_12.jpeg"];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

#pragma mark <UICollectionViewDataSource>

- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {
    return self.listArray.count;
}

- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
    FitnessVideoCollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:reuseIdentifier forIndexPath:indexPath];
    // Configure the cell
    cell.nameLable.text = self.listArray[indexPath.row];
    [cell.imageView1 sd_setImageWithURL:[NSURL URLWithString:self.urlArrs[indexPath.row]]];
//    cell.imageView1.layer.masksToBounds = YES;
//    cell.imageView1.layer.borderColor = [[UIColor whiteColor] CGColor];
//    cell.imageView1.layer.borderWidth = 2.0f;
//    cell.imageView1.layer.cornerRadius = (self.view.frame.size.width - 15) / 2 / 2.0f;
    return cell;
}

- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath
{
    TrainingTableViewController *train = [[TrainingTableViewController alloc] init];
    train.index = indexPath.row;
    train.string = self.listArray[indexPath.row];
    [self.navigationController pushViewController:train animated:YES];
}

#pragma mark <UICollectionViewDelegate>

/*
// Uncomment this method to specify if the specified item should be highlighted during tracking
- (BOOL)collectionView:(UICollectionView *)collectionView shouldHighlightItemAtIndexPath:(NSIndexPath *)indexPath {
	return YES;
}
*/

/*
// Uncomment this method to specify if the specified item should be selected
- (BOOL)collectionView:(UICollectionView *)collectionView shouldSelectItemAtIndexPath:(NSIndexPath *)indexPath {
    return YES;
}
*/

/*
// Uncomment these methods to specify if an action menu should be displayed for the specified item, and react to actions performed on the item
- (BOOL)collectionView:(UICollectionView *)collectionView shouldShowMenuForItemAtIndexPath:(NSIndexPath *)indexPath {
	return NO;
}

- (BOOL)collectionView:(UICollectionView *)collectionView canPerformAction:(SEL)action forItemAtIndexPath:(NSIndexPath *)indexPath withSender:(id)sender {
	return NO;
}

- (void)collectionView:(UICollectionView *)collectionView performAction:(SEL)action forItemAtIndexPath:(NSIndexPath *)indexPath withSender:(id)sender {
	
}
*/

@end
